//
//  WZAlarmPickerView.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/8/10.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "WZAlarmPickerView.h"

@interface WZAlarmPickerView ()

@property (nonatomic, strong) NSArray *pickerArray1;
@property (nonatomic, strong) NSArray *pickerArray2;

@end

@implementation WZAlarmPickerView

// 创建pickerView
- (void)addPickerView {
    
    UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, HARDWARE_SCREEN_HEIGHT, HARDWARE_SCREEN_WIDTH, 260)];

    UIToolbar *pickerToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, HARDWARE_SCREEN_WIDTH, 44)];
    pickerToolBar.barStyle = UIBarStyleDefault;
    [pickerToolBar sizeToFit];
    [containerView addSubview:pickerToolBar];

    UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancelBtnDidClick)];

    UIBarButtonItem *toobarDoneBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(doneBtnDidClick)];

    UIBarButtonItem *fixSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];

    pickerToolBar.items = @[cancelBtn, fixSpace, toobarDoneBtn];

//    UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, self.view.height, self.view.width, 260)];
//    pickerView.showsSelectionIndicator = YES;
//    pickerView.delegate = self;
//    pickerView.dataSource = self;
//    pickerView.backgroundColor = [UIColor whiteColor];
////    pickerView.inputAccessoryView = pickerToolBar;
//    [self.view addSubview:pickerView];
//    self.pickerView = pickerView;
}




//#pragma mark -- pickerView delegate

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {

    return 2;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {

    if (0 == component) {

        return 10;
    }

    return 3;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

    if (0 == component) {
        return self.pickerArray1[row];
    }

    return self.pickerArray2[row];
}

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
    
    return 40;
}

- (NSArray *)pickerArray1 {
    
    if (_pickerArray1 == nil) {
        _pickerArray1 = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", nil];
    }
    return _pickerArray1;
}

- (NSArray *)pickerArray2 {
    
    if (_pickerArray2 == nil) {
        _pickerArray2 = [NSArray arrayWithObjects:@"天", @"时", @"分", nil];
    }
    return _pickerArray2;
}

@end
